<html>
<head>
<title></title>
<link rel='icon' href='test.png'>
<script type='text/javascript' language='javascript'>
function removeLinkIfExists() {
  var docHead = document.getElementsByTagName("head")[0];
  var links = docHead.getElementsByTagName("link");
  for (var i=0; i<links.length; i++) {
    var link = links[i];
    if (link.type=="image/x-icon" && link.rel=="shortcut icon") {
      docHead.removeChild(link);
      return; // Assuming only one match at most.
    }
  }
}

function addLink(iconURL) {
  var docHead = document.getElementsByTagName("head")[0];
  var link = document.createElement("link");
  link.type = "image/x-icon";
  link.rel = "shortcut icon";
  link.href = iconURL;
  removeLinkIfExists();
  docHead.appendChild(link);
}

function OnLoad() {
 addLink("test1.png");
}

</script>
</head>
<body onload='OnLoad();'>
<a name='test'>
</body>
</html>